#!/usr/bin/env python 
# encoding: utf-8 
# @Author: Jacqueline
# @file: 01模拟鼠标操作.py
# @time: 2021/2/22 16:43
""
'''
1.点击
    单
    双
    右
2.拖拽
'''
from selenium import webdriver
from selenium.webdriver import ActionChains
driver = webdriver.Chrome()
driver.implicitly_wait(5)

driver.get('https://www.runoob.com/try/try.php?filename=jqueryui-api-droppable')
iframe = driver.find_element_by_id('iframeResult')
driver.switch_to.frame(iframe)

ele1 = driver.find_element_by_id('draggable')
ele2 = driver.find_element_by_id('droppable')

action_1 = ActionChains(driver)
action_1.move_to_element_with_offset(ele1,200,0)
# 1.选择拖拽的节点
sli_ele = driver.find_element_by_id('tcaptcha_thumb')
# 2.创建鼠标对象
action = ActionChains(driver)
# ——————————————单击——————————————————
action.click(sli_ele)#添加到动作列
action.perform()#执行动作
#———————————————右击每次重新创建鼠标对象—
r_action = ActionChains(driver)
r_action.context_click(sli_ele)
action.perform()
#———————————————双击——————————————————
double_action = ActionChains(driver)
double_action.double_click(sli_ele)
action.perform()
#————————————鼠标拖拽————————————————
tz_action = ActionChains(driver)
tz_action.click_and_hold(sli_ele)
tz_action.move_by_offset(xoffset=180,yoffset=0)
tz_action.release()
tz_action.perform()